package com.share.base.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

public interface IBaseDao<T,PK extends Serializable> {

	// -------------------- 基本检索、增加、修改、删除操作 --------------------
	/**
	 * 获取全部实体
	 * @param criterions
	 * @return
	 */
	public List<T> loadAll();
	
	public void save(final T entity);
	
    public void update(T entity);
    public void saveOrUpdate(T entity);
    public void saveOrUpdateAll(Collection<T> entities);
	public T get(final PK id);
    public void delete(T entity);
    public void deleteAll(Collection<T> entities);
	public int getAllRowCount(String hql);

	public PaginationSupport findPageByCriteria(int start,int limit);
	public List<T> findPageByCriteria(final DetachedCriteria detachedCriteria);
	public List<T> findByProperty(String propertyname,String flag,Object value);
    public List<T> findByProperty(String propertyName, Object value);
	public PaginationSupport findByProperties(List<Parameter> list,int startIndex,int pageSize);
    /** *//**  
     * 根据hql加载分页，指定页大小和起始位置  
     */  
    public PaginationSupport findPageByQuery(final String hql, final int pageSize, final int startIndex, Object...values);
}
